<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>事件</title>
	<script type="text/javascript">
		window.onload = function  () {
			//捉标签
			btn = document.getElementById("btn");
			//加事件
			num =1;
			btn.ondblclick  = function  () {
				//事件触发要执行的代码
				if(num==1){
					btn.style.width="300px";
					num=0;
				}else{
					btn.style.width="100px";
					num=1;
				}
				
			}

			username = document.getElementById("username");

			username.onkeydown  = function  () {
				

				// box.style.display= "block";
			}


			box = document.getElementById('box');

			box.onmouseover = function  () {
				box.style.backgroundColor='blue';
				
			}

			box.onmouseout = function  () {
				box.style.backgroundColor='green';
			}



		}

	</script>
	<style type="text/css">
		.box{
			width: 200px;
			height: 200px;
			background: red url() 0 0 no-repeat;
			/*display: none;*/
		}
	</style>
</head>
<body>
	<input type="button" id="btn" value="点我一下">

	<input type="text" id="username">

	<div class="box" id="box">这个是一个盒子</div>
</body>
</html>